#!/usr/bin/make -f
# -*- makefile -*-
# Makefile for MRPT Debian package.

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS=hardening=+all,+fortify

# For multiarch support:
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_TARGET_MULTIARCH ?= $(shell dpkg-architecture -qDEB_TARGET_MULTIARCH)

CMAKE_FLAGS = \
	-DCMAKE_INSTALL_LIBDIR="lib/$(DEB_TARGET_MULTIARCH)" \
	-DCMAKE_BUILD_TYPE=Release  \
	$(CMAKE_ARCH_FLAGS)

# Don't set: CMAKE_SKIP_RPATH=ON --> it makes unit tests to fail,
# and the rpath is removed anyway by cmake's install target.

%:
	dh $@ --buildsystem=cmake

override_dh_auto_build-arch:
	dh_auto_build -O--buildsystem=cmake

#override_dh_auto_build-indep:
#	# Build doc targets:
#	dh_auto_build -O--buildsystem=cmake -- docs

override_dh_auto_configure:
	# Show CPU flags, to help debugging unit test crashes related to
	# illegal instructions, etc.
	cat /proc/cpuinfo
	# Show env vars for debugging:
	env
	# Autoconfigure step:
	dh_auto_configure -- $(CMAKE_FLAGS)

override_dh_missing:
	dh_missing --list-missing
